package com.ccc.ka.util;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.lang.UUID;
import cn.hutool.http.HttpStatus;

import java.util.Map;

public class BaseController {
    protected KAResponse success(Object obj){
        return customize(HttpStatus.HTTP_OK, "success", obj);
    }

    protected KAResponse fail(Object obj){
        return customize(HttpStatus.HTTP_CONFLICT, "fail", obj);
    }

    protected KAResponse customize(int code, String msg, Object obj){
        return new KAResponse(code, msg, obj);
    }

    protected String UUID(){
        return UUID.fastUUID().toString(true);
    }

    protected Map<String, Object> beanToMap(Object object){
        return BeanUtil.beanToMap(object, true, true);
    }
}
